home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 May / CMCD0504.ISO / Software / Freeware / Programare / gdiplusdelphi / demos / Using Images, Bitmaps, and Metafiles / Reading and Writing Metadata / Write / Unit1.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2002-02-15  |  1.2 KB  |  58 lines

  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  7.   Dialogs, GDIPAPI, GDIPOBJ, GDIPUTIL, StdCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Button1: TButton;
  12.     Memo1: TMemo;
  13.     procedure Button1Click(Sender: TObject);
  14.   private
  15.     { Private declarations }
  16.   public
  17.     { Public declarations }
  18.   end;
  19.  
  20. var
  21.   Form1: TForm1;
  22.  
  23. implementation
  24.  
  25. {$R *.dfm}
  26.  
  27. procedure TForm1.Button1Click(Sender: TObject);
  28. var
  29.   stat : TStatus;
  30.   clsid: TGUID;
  31.   propertyValue: PChar;
  32.   Bitmap: TGPBitmap;
  33.   propertyItem: TPropertyItem;
  34. begin
  35.    propertyValue := PChar('Fake Photograph');
  36.  
  37.    Bitmap:= TGPBitmap.Create('..\untitled.JPG');
  38.  
  39.    // Get the CLSID of the JPEG encoder.
  40.    GetEncoderClsid('image/jpeg', clsid);
  41.    propertyItem.id := PropertyTagImageTitle;
  42.    propertyItem.length := 16;  // string length including NULL terminator
  43.    propertyItem.type_ := PropertyTagTypeASCII;
  44.    propertyItem.value := propertyValue;
  45.  
  46.    bitmap.SetPropertyItem(propertyItem);
  47.    stat := bitmap.Save('untitled2.JPG', clsid, nil);
  48.    if(stat = Ok) then
  49.      memo1.Lines.Add('untitled2.JPG saved successfully.');
  50.  
  51.   Bitmap.Free;
  52.  
  53. end;
  54.  
  55.  
  56.  
  57. end.
  58.